package com.example.soscall;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.databinding.BindingAdapter;

import com.ecarx.xui.adaptapi.oncall.Call;
import com.example.soscall.utils.CallHelper;
import com.example.soscall.utils.TimeUtil;


public class MyBindAdapter {


    @BindingAdapter({"state"})
    public static void setTextState(TextView view, int  callState) {
        switch (callState) {
            case Call.CALL_STATUS_IDLE:
                break;
            case Call.CALL_STATUS_START_FAILED:
                view.setText(R.string.state_call_start_fail);
                break;
            case Call.CALL_STATUS_CONNECT_FAILED:
            case Call.CALL_STATUS_DIAL_FAILED:
            case Call.CALL_STATUS_DATA_UPLOAD_FAILED:
                view.setText(R.string.state_call_failed);
                break;
            case Call.CALL_STATUS_BUSY:
                break;
            case Call.CALL_STATUS_REJECTED:
            case Call.CALL_STATUS_CALLBACK_REJECTED:
                view.setText(R.string.state_call_rejected);
                break;
            case Call.CALL_STATUS_DIALING:
            case Call.CALL_STATUS_RINGING:
            case Call.CALL_STATUS_CONNECTING:
            case Call.CALL_STATUS_CALL_CONNECTED:
                view.setText(R.string.state_calling);
                break;
            case Call.CALL_STATUS_DATA_UPLOADING:
                view.setText(R.string.state_start_call);
                break;
            case Call.CALL_STATUS_OFFHOOK:
                break;
            case Call.CALL_STATUS_IN_COMING_CALL:
                view.setText(R.string.state_incoming_call);
                break;

            case Call.CALL_STATUS_HANGING_UP:
                view.setText(R.string.state_hangup_call);
                break;
            case Call.CALL_STATUS_END:
//                stopTime();
                view.setText(R.string.state_end_call);
                break;
            case Call.CALL_STATUS_NOT_SUBSCRIBED:
                view.setText(R.string.state_no_subscribed);
                break;
            case Call.CALL_STATUS_IN_ECALL_CALLBACK:
                view.setText(R.string.state_redialling);
                break;
            default:
                break;
        }
    }
//    @BindingAdapter({"duringTime"})
//    public static void setDuringTime(TextView view, int  duringTime) {
//        view.setText(TimeUtil.formatCallTime(duringTime));
//    }

}
